#!/bin/sh

set -x

enable()
{
	# no need for ubuntu 16.04
	#nmcli nm wifi off
	rfkill unblock wlan

	ifconfig wlan0 192.168.222.1 up

	hostapd -B /etc/hostapd/hostapd.conf

	echo 1 >/proc/sys/net/ipv4/ip_forward 

	iptables -t nat -A POSTROUTING -s 192.168.222.0/24  -j SNAT --to-source 10.1.22.35
}


disable()
{
	killall hostapd

	echo 0 >/proc/sys/net/ipv4/ip_forward 

	iptables -t nat -F
}


case $1 in
	e|enable)
		enable
	;;
	d|disable)
		disable
	;;
	*)
		echo "$0 enable | disable"
	;;
esac
